#include <iostream>
#include <cstring>
#include <string>
#include <sstream>

using namespace std;

void test()
{
    string s("123 a");
    int num1 = 0;
    int num2 = 0;
    
    //whitespace is delim
    //123 to num1, a to num2
    //but a is char not int
    //iss become into failstream
    istringstream iss(s);
    iss >> num1 >> num2;
    cout << num1 << endl;
    cout << num2 << endl;

    if(iss.fail())
    {
        iss.clear();
        cout << "Fail stream" << endl;
    }
}

void test1()
{
    //string output
    //make any class into string
    //custom class need overload operator<<
    int num1 = 123, num2 = 456;
    ostringstream oss;
    oss << "num1 = " << num1 << ", num2 = " << num2 << endl;
    
    string str = oss.str();

    cout << str << endl;

    string str2("hello");
    str2 += " " + oss.str();

    cout << str2 << endl;
}

int main()
{
    test1();
    return 0;
}

